package com.byxy.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import com.byxy.entity.Reply;

public interface ReplyDao {
//	 `reply_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '鍥炲id',
//	  `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '鍥炲浜篿d',
//	  `tip_id` int(11) NOT NULL DEFAULT '0' COMMENT '琚洖澶嶈创id',
//	  `reply_content` text COLLATE utf8_bin NOT NULL COMMENT '鍥炲鍐呭',
//	  `reply_publishTime` datetime DEFAULT NULL COMMENT '鍥炲鍙戣〃鏃堕棿',
//	  `reply_modifyTime` datetime DEFAULT NULL COMMENT '鍥炲淇敼鏃堕棿',
//	  `reply_status` int(11) NOT NULL DEFAULT '0' COMMENT '鍥炲鐘舵�侊紝0姝ｅ父锛�1閫昏緫鍒犻櫎',
	@Results(id="replyMap",value={
		@Result(column="reply_id",property="replyId",id=true),
		@Result(column="user_id",property="user",one=@One(select="com.byxy.dao.UserDao.getById",fetchType=FetchType.EAGER)),
		@Result(column="tip_id",property="tip",one=@One(select="com.byxy.dao.TipDao.findById",fetchType=FetchType.EAGER)),
		@Result(column="reply_content",property="replyContent"),
		@Result(column="reply_publishTime",property="replyPublishTime"),
		@Result(column="reply_modifyTime",property="replyModifyTime"),
		@Result(column="reply_status",property="replyStatus")
	})
	@Select("select * from reply ")
	List<Reply> findById(Integer tipId);
	
	
	@Insert("insert into reply(user_id,tip_id,reply_content,reply_publishTime,reply_modifyTime,reply_status) "
			+ "values(#{user.userId},#{tip.tipId},#{replyContent},#{replyPublishTime},#{replyModifyTime},#{replyStatus})")
	void myReply(Reply reply);
}
